#include "Pos4PiSource.hh"

Pos4PiSource::Pos4PiSource(): MyBasePos()
{
    m_BoxLength = 30;
    m_BallRadius = 500;
}

std::pair<G4ThreeVector, G4ThreeVector> Pos4PiSource::GenPosAndMomDir()
{
    G4double theta = acos(2*(G4UniformRand()-0.5));
    G4double phi = 2 * G4UniformRand() * M_PI;
    G4double myX = m_BoxLength * (G4UniformRand() - 0.5);
    G4double myY = m_BoxLength * (G4UniformRand() - 0.5);

    std::pair<G4ThreeVector, G4ThreeVector> PosAndMomDir;

    PosAndMomDir.first = G4ThreeVector(-myX * sin(phi) + myY * cos(theta) * cos(phi) + m_BallRadius * sin(theta) * cos(phi),
                                      myX * cos(phi) + myY * cos(theta) * sin(phi) + m_BallRadius * sin(theta) * sin(phi),
                                      -myY * sin(theta) + m_BallRadius * cos(theta)) * cm;
    PosAndMomDir.second = G4ThreeVector(-sin(theta) * cos(phi), -sin(theta) * sin(phi), -cos(theta));
    return PosAndMomDir;
}

REGISTPOSGEN(Pos4PiSource)